<template>

    <el-button  @click="dialogVisible=true" color="#626aef" :dark="isDark">添加</el-button>

    <el-dialog v-model="dialogVisible" title="Tips" width="30%" :before-close="handleClose">
        <span>This is a message</span>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false;open4()">关闭</el-button>
                <el-button :plain="true" type="primary" @click="dialogVisible=false;open2()">
                    添加
                </el-button>
            </span>
        </template>
    </el-dialog>
</template>
  
<script  setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'


const open2 = () => {
  ElMessage({
    message: '添加成功',
    grouping:true,
    type: 'success',
  })
}

const open4 = () => {
  ElMessage({
    showClose: true,
    message: '添加失败',
    grouping:true,
    type: 'error',
  })
}



const dialogVisible = ref(false)
const handleClose = () => {
  dialogVisible.value = false
}

</script>
<style scoped>
.dialog-footer button:first-child {
    margin-right: 10px;
}
</style>